﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineAuction.App_Code;

namespace OnlineAuction.Guest
{
    public partial class KichHoatTaiKhoan : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnDangNhap_Click(object sender, EventArgs e)
        {
            try
            {
                string username = (string)Session["username"];
                string password = (string)Session["password"];
                string makichhoat = (string)Session["makichhoat"];

                MaHoaMatKhau maHoaMatKhau = new MaHoaMatKhau();
                string inputpass = maHoaMatKhau.EncriptMD5(txtPassword.Text);
                
                if((username==txtUsername.Text) &&
                   (password==inputpass) &&
                   (makichhoat==txtMaKichHoat.Text))
                {
                    int trangthai = 2; //Da kich hoat
                    //ghi trang thai xuong co so du lieu
                    DauGiaDataContext context = new DauGiaDataContext();
                    int kq = context.ThayDoiTrangThaiTaiKhoanNguoiDung(trangthai, username);
                    if(kq==0) //Thong tin kich hoat duoc luu thanh cong
                    {
                        Label5.Text = "";
                        Label7.Text = "Bạn đã kích hoạt tài khoản thành công.";
                        Session.Timeout = 30;
                        Label8.Text = "Xin chờ trong giây lát...";
                        Response.AddHeader("REFRESH","5;url=../NormalUser/Default.aspx");
                    }
                    else //Kich hoat that bai
                    {
                        Label5.Text = "Thông tin kích hoạt chưa chính xác. Vui lòng kiểm tra lại!";
  
                    }
                    
                    
                }

            }
            catch (Exception ex)
            {
                throw;
            }

        }
    }
}
